/**
 * 漫游摄像机 - L5
 * Created by lonphy on 2015/5/22.
 */
(function (L5) {
	"use strict";
	L5.RoamingCamera = class {
		/**
		 * 漫游摄像机构造器
		 * @param eye {L5.Vec3} 摄像机位置
		 * @param at {L5.Vec3} 观察的目标位置点
		 * @param up {L5.Vec3} 摄影坐标系Y轴上方向
		 */
		constructor(eye, at, up) {
			this.eye = eye;
			this.at = at;
			this.up = up;

			this._moveSpeed = 0;
		}
		// 摄像机移动速度
		set moveSpeed(speed) { this._moveSpeed = speed || 0; }
		get moveSpeed() { return this._moveSpeed; }

		/**
		 * 更新摄像机
		 */
		update(gl, fps, time) {
			// 帧频跳动补偿

			let radius = 80;	// 旋转半径
			let theta = time/1000/this._moveSpeed;

			this.eye.x = Math.sin(theta) * radius;
			this.eye.z = Math.cos(theta) * radius;
			//this.eye.y = Math.abs(Math.sin(theta))*radius;
		}

		toArray() {
			return L5.Matrix.lookAt(this.eye.clone(), this.at.clone(), this.up.clone());
		}
	};
})(window.L5);